#! /bin/bash

KVER=2.6.24
TCVER=4.3a

yum install sparse yum-utils 

yumdownloader --source kernel
rpm -ivh kernel-$(uname -r).src.rpm

rpmbuild -bp --target=noarch /usr/src/redhat/SPECS/kernel.spec
cp /usr/src/redhat/BUILD/kernel-${KVER}/linux-${KVER}.noarch/drivers/md/dm.h /usr/src/kernels/`uname -r`-`uname -p`/drivers/md

#curl -O  http://www.truecrypt.org/downloads/truecrypt-${TCVER}-source-code.tar.gz

tar -xzf "truecrypt-${TCVER}-source-code.tar.gz"

#curl -O  http://www.linuxlove.org/for2.6.23.patch
#patch -p1 -i for2.6.23.patch

pushd .

cd truecrypt-${TCVER}-source-code/Linux/

# This is from : http://blog.gnu-designs.com/building-truecrypt-v43a-modules-on-2623-kernels
patch --ignore-whitespace -p0 -i ../../2.6.23and24.patch
./build.sh 

#cd truecrypt-${TCVER}-source
#make 

popd

cp truecrypt-${TCVER}-source-code/Linux/Cli/truecrypt .
cp truecrypt-${TCVER}-source-code/Linux/Kernel/truecrypt.ko .

#rm -rf truecrypt-${TCVER}-source-code
